public class Test04 {
    public static int mySqrt(int x) {

        int left = 0;
        int right = x;
        int t = -1;
        while(left<=right){
            int mid  = left + (right-left)/2;
            long tmp = mid*mid;
            if(tmp>x){
                right = mid-1;
            }else{
                t = mid;
                left = mid+1;
            }
        }
        return t;

    }

    public static void main(String[] args) {
       int a =  mySqrt(Integer.MAX_VALUE);
        System.out.println(a);
    }
}
